//
//  NSDecimalNumber+Addition.h
//  num
//
//  Created by ddy on 2019/1/9.
//  Copyright © 2019年 cycle. All rights reserved.
//  数字精度不丢

#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, calculationType) {
    
    Add,
    
    Subtract,
    
    Multiply,
    
    Divide
    
};
NS_ASSUME_NONNULL_BEGIN

@interface NSDecimalNumber (Addition)

+(NSDecimalNumber *)aDecimalNumberWithStringOrNumberOrDecimalNumber:(id)stringOrNumber1 type:(calculationType)type anotherDecimalNumberWithStringOrNumberOrDecimalNumber:(id)stringOrNumber2 andDecimalNumberHandler:(NSDecimalNumberHandler *)handler;


+(NSComparisonResult)aDecimalNumberWithStringOrNumberOrDecimalNumber:(id)stringOrNumber1 compareAnotherDecimalNumberWithStringOrNumberOrDecimalNumber:(id)stringOrNumber2;

+(NSString *)stringWithDecimalNumber:(NSDecimalNumber *)str1 scale:(NSInteger)scale;


extern NSComparisonResult StrNumCompare(id str1,id str2);

extern NSDecimalNumber *handlerDecimalNumber(id strOrNum,NSRoundingMode mode,int scale);


extern NSComparisonResult SNCompare(id strOrNum1,id strOrNum2);


extern NSDecimalNumber *SNAdd(id strOrNum1,id strOrNum2);

extern NSDecimalNumber *SNSub(id strOrNum1,id strOrNum2);

extern NSDecimalNumber *SNMul(id strOrNum1,id strOrNum2);

extern NSDecimalNumber *SNDiv(id strOrNum1,id strOrNum2);

extern NSDecimalNumber *SNMin(id strOrNum1,id strOrNum2);

extern NSDecimalNumber *SNMax(id strOrNum1,id strOrNum2);

extern NSDecimalNumber *SNAdd_handler(id strOrNum1,id strOrNum2,NSRoundingMode mode,int scale);

extern NSDecimalNumber *SNSub_handler(id strOrNum1,id strOrNum2,NSRoundingMode mode,int scale);

extern NSDecimalNumber *SNMul_handler(id strOrNum1,id strOrNum2,NSRoundingMode mode,int scale);

extern NSDecimalNumber *SNDiv_handler(id strOrNum1,id strOrNum2,NSRoundingMode mode,int scale);

extern NSDecimalNumber *SNMin_handler(id strOrNum1,id strOrNum2,NSRoundingMode mode,int scale);

extern NSDecimalNumber *SNMax_handler(id strOrNum1,id strOrNum2,NSRoundingMode mode,int scale);
/*
 NSDecimalNumber *num = [[NSDecimalNumber alloc] initWithString:@"0.00"];
 NSDecimalNumber *num1 = [[NSDecimalNumber alloc] initWithString:@"0.2991"];
 NSDecimalNumber *num2 = [[NSDecimalNumber alloc] initWithString:@"10000"];
 
 //加法运算
 //    num = SNAdd(num1,num2);
 //减法运算
 //    num = SNSub(num1,num2);
 //    //乘法运算
 num = SNMul(num1,num2);
 //    //除法运算
 //    num = SNDiv(num1,num2);
 //加法乘法混合运算
 //    num = SNAdd(SNMul(@(数量),价格), num2);4.567
 //最终结果
 NSString *result = [NSString stringWithFormat:@"%f---%@",[num doubleValue],num];
 
 NSLog(@"%@",result);
 */

@end

NS_ASSUME_NONNULL_END
